<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>

<%@ page import="cn.yiban.open.Uis" %>
<%
  if (request.getMethod() == "POST")
  {
    /**
     * 使用时，需要用以下命令将RSA的私钥转为PKCS8格式
     *
     * # openssl pkcs8 -topk8 -in RSA的私钥文件 -out pkcs8_rsa_private_key.pem -nocrypt
     */
    String school_id = "学校ID";
    String priv_file = "PKCS8格式编码私钥文件路径";

    try
    {
      Uis uis = Uis.getInstance();
      uis.setup(response, school_id, priv_file);

      Enumeration<String> params = request.getParameterNames();
      Map<String, String> result = new HashMap<String, String>();
      while (params.hasMoreElements())
      {
        String name = params.nextElement();
        String value = request.getParameter(name);
        result.put(name, value);
      }
      uis.run(result, true);
    }
    catch(Exception e)
    {
      out.println(e.getMessage());
    }
    return;
  }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>学校uis身份验证</title>
  <link href="default.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="main">
  <form action="" method="post" id="check_sc" name="check_sc">
    <div>姓名：<input type="text" id="name" name="name" /></div>
    <div>学号：<input type="text" id="student_id" name="student_id" /></div>
    <div>工号：<input type="text" id="teacher_id" name="teacher_id" /></div>
    <div>准考证号：<input type="text" id="exam_id" name="exam_id" /></div>
    <div>录取编号：<input type="text" id="enter_id" name="enter_id" /></div>
    <div>身份证号：<input type="text" id="status_id" name="status_id" /></div>
    <div>入学年份：<input type="text" id="enter_year" name="enter_year" /></div>
    <div>身份：<input type="text" id="role" name="role" /></div>
    <div>学院：<input type="text" id="college" name="college" /></div>
    <div>专业：<input type="text" id="specialty" name="specialty" /></div>
    <div>班级：<input type="text" id="eclass" name="eclass" /></div>
    <div>籍贯：<input type="text" id="native_place" name="native_place" /></div>
    <div><input type="button" value="验证" onclick="document.getElementById('check_sc').submit();" data-enhanced="true" /></div>
  </form>
</div>
</body>
</html>